package org.uma.kri.nyu.mor.almas.util;

import java.util.ArrayList;

import org.uma.kri.nyu.mor.almas.R;
import org.uma.kri.nyu.mor.almas.entity.Group;

import android.content.Context;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;

public class EditGroupAdapter extends ArrayAdapter<ArrayList<Group>> {

	private Context _context;
	private int _layout_id;
	private ArrayList<Group> _objects;
	private LayoutInflater _inflater;
	
	public EditGroupAdapter(Context context, int textViewResourceId,
			ArrayList<Group> groupList) {
		super(context, textViewResourceId);
		_context = context;
		_objects = groupList;
		_layout_id = textViewResourceId;
		_inflater = (LayoutInflater) _context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Resources res = _context.getResources();
		View view;

		if (convertView == null) {
			view = _inflater.inflate(_layout_id, null);
		} else {
			view = convertView;
		}
		
		view = LayoutInflater.from(_context).inflate(R.layout.editinfo_spinner_group, null);
		
		CheckBox groupCheck = (CheckBox) view.findViewById(R.id.editInfo_check_group);
		groupCheck.setText(_objects.get(position).groupName);
		groupCheck.setChecked(true);
		
//		return super.getView(position, convertView, parent);
		return view;	
	}
}
